package com.yootk.consumer.listener;

import com.yootk.common.Dept;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RabbitMQMessageListener {
    private static final Logger LOGGER = LoggerFactory.getLogger(RabbitMQMessageListener.class) ;
    @RabbitListener(
            queues = "muyan.consumer.queue",
            admin = "admin",
            containerFactory = "containerFactory"
    )
    public void sendMessage(List<Dept> depts) {
        LOGGER.info("**********************接收消息**************************");
        for (Dept dept : depts) {

            LOGGER.info("【接收消息】消息内容是：部门编号：{}部门名称：{}部门位置：{}", dept.getDeptno(), dept.getDname(), dept.getLoc());
        }
    }
}
